# -*- coding: utf-8 -*-
import time

from selenium import webdriver

browser = webdriver.Safari()

browser.get("http://m.xiaoxineye.com/wxaward/html5/games/eye/index.html?tdsourcetag=s_pcqq_aiomsg")

startBtn = browser.find_element_by_xpath("""//*[@id="index"]/div[2]/button""")

startBtn.click()

time.sleep(1)

for i in range(0, 1000):
    # time.sleep(0.35)
    box = browser.find_element_by_xpath("""//*[@id="box"]""")
    if None == box:
        break
    spans = box.find_elements_by_xpath("span")
    lastColor = None
    for i in range(0, len(spans)):
        newColor = spans[i].get_attribute("style")
        # print(newColor,':color')

        if lastColor != None and lastColor != newColor:
            # print (newColor,":找到了")
            lastColor = None
            if i == 1 and newColor == spans[i + 1].get_attribute("style"):
                spans[0].click()
            else:
                spans[i].click()

            break
        else:
            lastColor = newColor

# browser.quit()
